#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/15 21:50
# @Author: 张涛
# @Email: xxx@gmail.com
# @File：add_opt_page.py

from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from time import sleep

class AddOptPage(BasePage):
    """添加商机"""
    tjsjm_locator = (By.ID,'name')  #商机名
    tjkh_locator = (By.ID,'customer_name') #客户
    xzkh_locator = (By.XPATH,'/html/body/div[10]/div[2]/table/tbody[2]/tr[1]/td[1]/input[1]') #选择客户
    qrxzkh_locator = (By.XPATH,'/html/body/div[10]/div[3]/div/button[1]/span') #选择确定
    tjyjcjj_locator = (By.ID,'estimate_price') #商机成交价
    djbc_locator = (By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td/input[1]') #点击保存

    def tjsjm_element(self,tjsjm_a):
        '''添加商机名'''
        self.driver.find_element(*self.tjsjm_locator).send_keys(tjsjm_a)

    def tjkh_element(self):
        '''点击添加客户'''
        self.driver.find_element(*self.tjkh_locator).click()
        sleep(2)
        self.driver.find_element(*self.xzkh_locator).click()
        sleep(1)
        self.driver.find_element(*self.qrxzkh_locator).click()


    def tjyhcjj_element(self,tjyhcjj_a):
        '''输入用户成交价'''
        self.driver.find_element(*self.tjyjcjj_locator).send_keys(tjyhcjj_a)

    def djbc_element(self):
        '''点击保存'''
        self.driver.find_element(*self.djbc_locator).click()

    def addshangji(self,tjsjm_a,tjyhcjj_a):
        '''添加商机'''
        self.tjsjm_element(tjsjm_a)
        self.tjkh_element()
        self.tjyhcjj_element(tjyhcjj_a)
        self.djbc_element()


